import java.net.*;
import screen.*;

public class GetHostAddress {

   public static void main(String args[] ) {

	byte hostName[] = new byte[100];
	byte rawAddress[];
	InetAddress  inetAddress;
	while ( true ) {
	    System.out.print("\nEneter a host name: ");
	    try {
		System.in.read(hostName);
		inetAddress = InetAddress.getByName( new String(hostName).trim() );
		System.out.println();
		rawAddress = inetAddress.getAddress();
		System.out.println(ScreenIO.expandString(30, "Host raw IP Address: ") + (int) rawAddress[0] + " " + rawAddress[1] +
								rawAddress[1] + " " + rawAddress[2] + rawAddress[3] );
		System.out.println(ScreenIO.expandString(30, "Host IP Address: ") +  inetAddress.getHostAddress());
		System.out.println(ScreenIO.expandString(30, "Host Name: ") +  inetAddress.getHostName());
		System.out.println(ScreenIO.expandString(30, "Multicast Address? ") +  (inetAddress.isMulticastAddress() ? "true" : "false"));
		System.out.println(ScreenIO.expandString(30, "Local Host Inet Address: ") +  inetAddress.getLocalHost());
	   } catch ( Exception e ) { e.printStackTrace(); } 
	}
   }
}
